package com.hzbank.juc.introduction;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2023/12/18 - 14:08
 */
@Slf4j
public class Thread03 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<String> futureTask = new FutureTask<>(
                new Callable<String>() {
                    @Override
                    public String call() throws Exception {
                        log.debug("线程内部-");
                        Thread.sleep(1000);
                        return "run===========";
                    }
                }
        );
        Thread thread = new Thread(futureTask, "线程1号========");
        thread.start();

        String s = futureTask.get();
        log.debug("=============================" + s);

    }
}


